package frametest;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.ActionFactory;


public class MyAction extends Action implements ISelectionListener, ActionFactory.IWorkbenchAction{

	private final IWorkbenchWindow window;
	public final static String ID = "myAction";
	private IStructuredSelection selection;
	
	public MyAction(IWorkbenchWindow window)
	{
		this.window = window;
		setId(ID);
		setText(("&MyAction)"));
		setToolTipText("MyMy");
		window.getSelectionService().addSelectionListener(this);
		
	
	}
	
	public void dispose()
	{
		window.getSelectionService().removePostSelectionListener(this);
		
	}
	
	public void selectionChanged(IWorkbenchPart part, ISelection incoming)
	{
		if(incoming instanceof IStructuredSelection)
		{
			selection = (IStructuredSelection)incoming;
		}
		else
			setEnabled(false);
	}

	public void run()
	{
		System.out.println("Wododowowododowo");
	}
}
